package com.hashTable;

import java.util.HashMap;

public class TwoSum0131_1 {
    public int[] twoSum(int[] nums, int target) {
        HashMap<Integer, Integer> map = new HashMap<>(); //< target-val, index >

        for (int i = 0; i < nums.length; i++) {
            if(map.containsKey(nums[i])) return new int[]{i,map.get(nums[i])};
            map.put(target - nums[i], i);
        }
        return new int[2];
    }
}
